package cn.com.pansky.util;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class CardNumUtil {

	public static String cardNum(String CA006){
		char x = CA006.charAt(CA006.length()-1);
		if (x>='A' && x<='Z') {
			String xx = String.valueOf(x).toLowerCase();
			String str = CA006.substring(0, CA006.length()-1);
			str = str+xx;
			return str;
		}
		return CA006;
	}
	
	//验证手机号码
	public static boolean phoneNumber(String number){
		String rgx = "^((13[0-9])|(17[0-9])|(14[0-9])|(15[^4,\\D])|(18[0-9]))\\d{8}$";
		    
		return isCorrect(rgx, number);
	}
	  //验证身份证号码
	public static boolean idCardNumber(String number){
	    String rgx = "^\\d{15}|^\\d{17}([0-9]|X|x)$";
	    
	    return isCorrect(rgx, number);
	  }
	  
	  //正则验证
	public static boolean isCorrect(String rgx, String res){
	    Pattern p = Pattern.compile(rgx);
	    
	    Matcher m = p.matcher(res);
	    
	    return m.matches();
	  }

	public static void main(String[] args) {
		System.out.println(idCardNumber("142622199201071"));
	}
	
}
